import { Column, ManyToMany, JoinTable, PrimaryGeneratedColumn } from 'typeorm';
import { EntityModel } from '@midwayjs/orm';
import { SysUser } from './user';
import { SysMenu } from './menu';

@EntityModel('sys_role')
export class SysRole {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  name: string;

  @ManyToMany(() => SysUser, sysUser => sysUser.role)
  @JoinTable()
  user: SysUser[];

  @ManyToMany(() => SysMenu, sysMenu => sysMenu.roles)
  menus: SysMenu[];
}
